


#ifndef PF_FILTERINTERFACE_H
#define PF_FILTERINTERFACE_H

#include "pf_graphic.h"
#include "lx_Export.h"

/**
 * This is the interface that must be implemented for all 
 * format filter classes. The PF_FileIO class 
 * uses the methods defined in here to interact with the format
 * filter classes.
 *

 */
class LX_EXPORT PF_FilterInterface {
public:
    /**
     * Constructor.
     */
    PF_FilterInterface() {
		//std::cout << "PF_FilterInterface\n";
        //graphic = NULL;
    }

    /**
     * Destructor.
     */
    virtual ~PF_FilterInterface() {}

    /**
     * Checks if this filter can import the given file type.
     *
     * @retval true if the filter can import the file type 
     * @retval false otherwise.
     */
    virtual bool canImport(LX_Define::FormatType t) {
        return importFormats.contains(t);
    }

    /**
     * Checks if this filter can export the given file type.
     *
     * @return true if the filter can export the file type, 
     *         false otherwise.
     */
    virtual bool canExport(LX_Define::FormatType t) {
        return exportFormats.contains(t);
    }

    /**
     * The implementation of this method in a inherited format
     * class should read a file from disk and put the entities
     * into the current entity container.
     */
    virtual bool fileImport(PF_Graphic& g, const QString& file, LX_Define::FormatType type) = 0;

    /**
     * The implementation of this method in a inherited format
     * class should write the entities in the current entity container
     * to a file on the disk.
     */
    virtual bool fileExport(PF_Graphic& g, const QString& file, LX_Define::FormatType type) = 0;

protected:
    /**
     * Adds a file extension which can be imported by this filter.
     */
    void addImportFormat(LX_Define::FormatType type) {
        PF_DEBUG->print("Filter can import %d", (int)type);
        importFormats += type;
    }

    /**
     * Adds a file extension which can be exported by this filter.
     */
    void addExportFormat(LX_Define::FormatType type) {
        PF_DEBUG->print("Filter can export %d", (int)type);
        exportFormats += type;
    }

protected:
    //! Pointer to the graphic we currently operate on.
    //PF_Graphic* graphic;

    //! Vector of file extensions this filter can import.
    QList<LX_Define::FormatType> importFormats;

    //! Vector of file extensions this filter can export.
    QList<LX_Define::FormatType> exportFormats;
};

#endif
